//
// Created by 2592345590 on 2022/5/7.
//
#include <iostream>
#include "group/Group.h"
#include "Compiler/GAnalysis.h"
using namespace std;

int main(){
    cout<<"start"<<endl;
    GAnalysis gAnalysis1=GAnalysis();
    //GAnalysis gAnalysis2=GAnalysis();
    //GAnalysis gAnalysis3=GAnalysis();
    //GAnalysis gAnalysis4=GAnalysis();
    vector<GAnalysis> v;
    v.push_back(gAnalysis1);//v.push_back(gAnalysis2);v.push_back(gAnalysis3);v.push_back(gAnalysis4);
    string input;
    cout<<"请输入字符串(markzero退出程序):"<<endl;
    while(getline(cin,input)&&input!="markzero") {
        for(int i=0;i<v.size();i++){
            if(v[i].Analysis(input)){
                cout<<endl<<"文法G"<<i+1<<"识别成功"<<endl;
                break;
            }
        }
        cout<<"输入下一个需要识别的字符串(markzero退出程序):"<<endl;
    }

    cout<<endl<<"over";
    return 0;
}
/**
 * G1
L
id=E
E
E+T|T|E-T|T
T
(E)|id
markzero

 */
/**
 * G2
L
id=E
E
E-T|T|E*T
T
T/F|T%F|F
F
(E)|id
markzero

 **/
/**
 * G3
D
TL;
T
int|float
L
 idR
R
,idR|@
markzero

**/
/**
 * G4
L
E;L|@
E
TE'
E'
+TE'|-TE'|@
T
FT'
T'
*FT'|/FT'|mod FT'|@
F
(E)|id|num
markzero

 **/
/**
* G5
stmt
if expr then stmt else stmt|if expr then stmt|other
markzero

*/